
<script type="text/javascript">
	function AddProJs(url,field){
		var qty = document.getElementById(field).value;
		window.location = url+"&qty="+qty;
	}
	function JAccordion(opentr,obj){
		var getclass = $(obj).attr('class');
		if(getclass == 'arrow_down' && $('#'+opentr).css('display')=='none'){
			$(obj).removeClass('arrow_down');
			$(obj).addClass('arrow_up');
		}else{
			$(obj).removeClass('arrow_up');
			$(obj).addClass('arrow_down');
		}
		
		$('#'+opentr).toggle(200);
	}
	function CallDisCat(obj){
		var val = $(obj).val();
		window.location = "products.php?filter="+val;
	}
</script>
	<?php
				
					$getcat = mysql_query("SELECT * FROM category ORDER BY name");
					while($catrow = mysql_fetch_array($getcat)){
				?>
                    <tr>
                        <th colspan="7" id="j-cat-title" class="arrow_down" onClick="JAccordion('row_<?php echo $catrow['id'];?>',this)"><?php echo $catrow['name']; ?></th>
                    </tr>
                    <tr>
                    	<td colspan="7" style="padding:0px; display:none;" class="accorhide" id="row_<?php echo $catrow['id'];?>" >
                        	<div>
                     <?php	
					 
					 $getrelation = mysql_query("SELECT * FROM cat_items WHERE cat_id = ".$catrow['id']);
					 while($relationrow = mysql_fetch_array($getrelation)){
					 ?>
                     	
                     <?php
							$getproducts = mysql_query("SELECT * FROM items WHERE itemId = ".$relationrow['item_id']." ORDER BY itemName");
						
							while($p_data = mysql_fetch_array($getproducts)){
								
						?>
                        	<div class="detaildiv">
                                	<?php 
										include('prodetails.php');
									?>
                  			 </div>
						<?php
							}
						?>
                     
                <?php	
					 	}
				?>	
                			</div>
                </td>
                	</tr>
                <?php
					}
				
				?>